using System.ComponentModel;

namespace CthulhuDomain.GameEntities
{
  public abstract class PowerUpFactory
  {
    public enum ePowerUp
    {
      None = 0,
      Player_Speed = 1,
      Player_Slow = 2,
      Life = 3,
      Army_Speed = 4,
      Army_Slow = 5,
      Player_Bullet_Speed = 6,
      Player_Bullet_Slow = 7,
      Army_Bullet_Speed = 8,
      Army_Bullet_Slow = 9
    }

    protected ePowerUp TPowerUp;
    public static PowerUpFactory GetFactory(ePowerUp type) {
      PowerUpFactory factory;
      switch (type) {
        case ePowerUp.Life:
          factory = new LifePowerUpFactory();
          break;
        case ePowerUp.Player_Speed:
        case ePowerUp.Player_Slow:
          factory = new PlayerSpeedChangeFactory(type);
          break;
        case ePowerUp.Army_Speed:
        case ePowerUp.Army_Slow:
          factory = new ArmySpeedChangeFactory(type);
          break;
        case ePowerUp.Player_Bullet_Speed:
        case ePowerUp.Player_Bullet_Slow:
          factory = new PlayerBulletSpeedChangeFactory(type);
          break;
        case ePowerUp.Army_Bullet_Speed:
        case ePowerUp.Army_Bullet_Slow:
          factory = new ArmyBulletSpeedChangeFactory(type);
          break;
        default:
          throw new InvalidEnumArgumentException();
      }
      return factory;
    }

    public abstract DomainEntity CreatePowerUp();
    public abstract DomainEntity CreatePowerUp(IContentManager manager);
  }


  internal class ArmyBulletSpeedChangeFactory : PowerUpFactory
  {
    public ArmyBulletSpeedChangeFactory(ePowerUp type) {
      TPowerUp = type;
    }

    public override DomainEntity CreatePowerUp() {
      var entity = new PowerUp {
        Power = new BulletSpeedImplementator(PowerImplementator.eTargetEntity.Army, TPowerUp) { TextMessage = string.Format("Army {0} bullets speed!", TPowerUp == ePowerUp.Army_Bullet_Speed ? "gain" : "loose") },
        Height = 28,
        Width = 22,
      };
      return entity;


    }

    public override DomainEntity CreatePowerUp(IContentManager manager) {
      var entity = new PowerUp {
        Power = new BulletSpeedImplementator(PowerImplementator.eTargetEntity.Army, TPowerUp) { TextMessage = string.Format("Army {0} bullets speed!", TPowerUp == ePowerUp.Army_Bullet_Speed ? "gain" : "loose") },
        Height = 28,
        Width = 22,
      };
      return entity;
    }
  }

  internal class PlayerBulletSpeedChangeFactory : PowerUpFactory
  {
    public PlayerBulletSpeedChangeFactory(ePowerUp type) {
      TPowerUp = type;
    }

    public override DomainEntity CreatePowerUp() {
      var entity = new PowerUp {
        Power = new BulletSpeedImplementator(PowerImplementator.eTargetEntity.Player, TPowerUp) { TextMessage = string.Format("Player {0} bullets speed!", TPowerUp == ePowerUp.Player_Bullet_Speed ? "gain" : "loose") },
        Height = 28,
        Width = 22,
      };
      return entity;
    }

    public override DomainEntity CreatePowerUp(IContentManager manager) {
      var entity = new PowerUp {
        Power = new BulletSpeedImplementator(PowerImplementator.eTargetEntity.Player, TPowerUp) { TextMessage = string.Format("Player {0} bullets speed!", TPowerUp == ePowerUp.Player_Bullet_Speed ? "gain" : "loose") }
      ,
        Height = 28,
        Width = 22,
      };
      return entity;
    }
  }

  internal class ArmySpeedChangeFactory : PowerUpFactory
  {
    public ArmySpeedChangeFactory(ePowerUp type) {
      TPowerUp = type;
    }

    public override DomainEntity CreatePowerUp() {
      var entity = new PowerUp {
        Power = new EntitySpeedImplementator(PowerImplementator.eTargetEntity.Army,
                                             TPowerUp) {
                                               TextMessage =
                                                 string.Format("Invaders {0} speed!",
                                                               TPowerUp == ePowerUp.Army_Speed ? "gain" : "loose")
                                             },
        Height = 27,
        Width = 23,


      };

      return entity;
    }

    public override DomainEntity CreatePowerUp(IContentManager manager) {
      var entity = new PowerUp {
        Power =
          new EntitySpeedImplementator(PowerImplementator.eTargetEntity.Army, TPowerUp) {
            TextMessage =
              string.Format("Invaders {0} speed!", TPowerUp == ePowerUp.Army_Speed ? "gain" : "loose")
          },
        Height = 27,
        Width = 23,

      };

      return entity;
    }
  }

  internal class PlayerSpeedChangeFactory : PowerUpFactory
  {
    public PlayerSpeedChangeFactory(ePowerUp type) {
      TPowerUp = type;
    }

    public override DomainEntity CreatePowerUp() {
      var entity = new PowerUp {
        Power =
          new EntitySpeedImplementator(PowerImplementator.eTargetEntity.Player, TPowerUp) { TextMessage = string.Format("Player {0} speed!", TPowerUp == ePowerUp.Player_Speed ? "gain" : "loose") },
        Height = 27,
        Width = 23,

      };
      return entity;
    }

    public override DomainEntity CreatePowerUp(IContentManager manager) {
      var entity = new PowerUp {
        Power =
          new EntitySpeedImplementator(PowerImplementator.eTargetEntity.Player, TPowerUp) { TextMessage = string.Format("Player {0} speed!", TPowerUp == ePowerUp.Player_Speed ? "gain" : "loose") },
        Height = 27,
        Width = 23
      };

      return entity;
    }
  }

  internal class LifePowerUpFactory : PowerUpFactory
  {
    private const string textMessage = "Player gain new Life!";

    public override DomainEntity CreatePowerUp() {
      var entity = new PowerUp {
        Power = new PlayerLifeImplementator { TextMessage = textMessage },
        Height = 26,
        Width = 23
      };

      return entity;
    }

    public override DomainEntity CreatePowerUp(IContentManager manager) {
      var entity = new PowerUp {
        Power = new PlayerLifeImplementator { TextMessage = textMessage },
        Height = 26,
        Width = 23
      };

      return entity;
    }
  }

}